﻿using System;
using System.Collections.Generic;
using System.Text;

namespace WGCSFramework.validations.numbers
{
    public class WgPorts
    {
        public int validatePortNumber(string port, int defaultPortNumber)
        {
            int newPort;
            try
            {
                newPort = Int16.Parse(port);
            }
            catch
            {
                newPort = defaultPortNumber;
            }
            return this.validatePortNumber(newPort, defaultPortNumber);
        }

        public int validatePortNumber(int port, int defaultPortNumber)
        {
            if (port < 1 || port > 999999) return defaultPortNumber;
            else return port;
        }
    }
}
